package com.andy.customerService.controller;


import com.andy.customerService.entity.Road;
import com.andy.customerService.service.RoadService;
import com.andy.customerService.vo.JsonBaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 线路 前端控制器
 * </p>
 *
 * @author Andy
 * @since 2022-02-24
 */
@RestController
@RequestMapping("/road")
public class RoadController {

    @Autowired
    private RoadService roadService;

    /**
     * 添加线路
     * @param road
     */
    @PostMapping("/add")
    public JsonBaseResult<Object> addRoad(@RequestBody Road road){
        return roadService.addRoad(road);
    }

    /**
     * 修改线路
     */
    @PutMapping("/edit")
    public JsonBaseResult<Object> editRoad(@RequestBody Road road){
        return roadService.editRoad(road);
    }

    /**
     * 根据角色获取线路
     * @param role
     */
    @GetMapping("/getRoad")
    public Road getRoadByRole(@RequestParam String role){
        return roadService.getRoadByRole(role);
    }
    /**
     * 线路列表
     */
    @GetMapping("/list")
    public JsonBaseResult<Object> roadList(){
        return roadService.roadList();
    }
}

